package com.artezio.buyndrive.dao.impl;

import com.artezio.buyndrive.dao.CityDAO;
import com.artezio.buyndrive.domain.City;
import com.artezio.buyndrive.domain.Country;
import org.hibernate.Criteria;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class CityDAOImpl extends AbstractHibernateDao<City> 
    implements CityDAO{
    
    @Autowired
    private SessionFactory sessionFactory;
   
    public CityDAOImpl() {
        super.setSessionFactory(sessionFactory);
    }

    public List getCitiesByCountID(Country country){

        Criteria criteria = getSession().createCriteria(City.class);
        return criteria.add(Restrictions.eq("idCountry", country)).list();
    }


}
